//
//  FondHotAndFondHeader.swift
//  Eternity
//
//  Created by cll12_12 on 2016/11/30.
//  Copyright © 2016年 ZhengWei. All rights reserved.
//

import UIKit

class FondHotAndFondHeader: UICollectionReusableView {
    
    // MARK: - life cycle
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        initBaseLayout()
        layoutPageSubviews()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    // MARK: - private method
    func initBaseLayout() {
        self.backgroundColor = UIColor.white
        self.addSubview(backView)
        self.addSubview(titleLabel)
        self.addSubview(arrowImageView)
    }
    
    func layoutPageSubviews() {
        backView.snp.makeConstraints { (make) in
            make.centerX.centerY.equalTo(self)
            make.width.equalTo(96)
            make.height.equalTo(14)
        }
        
        titleLabel.snp.makeConstraints { (make) in
            make.left.equalTo(backView).offset(10)
            make.centerY.equalTo(self)
            make.width.equalTo(56)
            make.height.equalTo(14)
        }
        
        arrowImageView.snp.makeConstraints { (make) in
            make.right.equalTo(backView).offset(-10)
            make.centerY.equalTo(self)
            make.width.equalTo(5)
            make.height.equalTo(9)
        }
    }
    
    // MARK: - setters and getters
    var _title: String?
    var title: String? {
        set {
            if newValue != nil {
                titleLabel.text = newValue
            }
        } get {
            return _title
        }
    }
    
    var _backView: UIView!
    var backView: UIView {
        if _backView == nil {
            _backView = UIView()
        }
        return _backView
    }
    
    var _titleLabel: UILabel!
    var titleLabel: UILabel {
        if _titleLabel == nil {
            _titleLabel = UILabel()
            _titleLabel.font = UIFont(name: "PingFangSC-Regular", size: 14)
            _titleLabel.textColor = UIColor(hexString: "#252525")
            _titleLabel.textAlignment = .center
        }
        return _titleLabel
    }
    
    var _arrowImageView: UIImageView!
    var arrowImageView: UIImageView {
        if _arrowImageView == nil {
            _arrowImageView = UIImageView()
            _arrowImageView.image = UIImage(named: "icon_arrow_r")
        }
        return _arrowImageView
    }
    
}
